from django.contrib import admin
from .models import Category, Solution, Insight, Event, Contact, Banner, Office

@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    list_display = ('name', 'parent', 'order')
    list_filter = ('parent',)
    search_fields = ('name', 'description')
    prepopulated_fields = {'slug': ('name',)}

@admin.register(Solution)
class SolutionAdmin(admin.ModelAdmin):
    list_display = ('title', 'category', 'is_featured', 'created_at', 'updated_at')
    list_filter = ('category', 'is_featured')
    search_fields = ('title', 'short_description', 'content')
    prepopulated_fields = {'slug': ('title',)}
    date_hierarchy = 'created_at'

@admin.register(Insight)
class InsightAdmin(admin.ModelAdmin):
    list_display = ('title', 'category', 'publication_date', 'is_featured')
    list_filter = ('category', 'is_featured', 'publication_date')
    search_fields = ('title', 'short_description', 'content')
    prepopulated_fields = {'slug': ('title',)}
    date_hierarchy = 'publication_date'

@admin.register(Event)
class EventAdmin(admin.ModelAdmin):
    list_display = ('title', 'event_date', 'location', 'is_online', 'is_featured')
    list_filter = ('is_online', 'is_featured', 'event_date')
    search_fields = ('title', 'short_description', 'content', 'location')
    prepopulated_fields = {'slug': ('title',)}
    date_hierarchy = 'event_date'

@admin.register(Contact)
class ContactAdmin(admin.ModelAdmin):
    list_display = ('name', 'email', 'company', 'position', 'created_at')
    list_filter = ('created_at',)
    search_fields = ('name', 'email', 'company', 'message')
    readonly_fields = ('created_at',)
    date_hierarchy = 'created_at'

@admin.register(Banner)
class BannerAdmin(admin.ModelAdmin):
    list_display = ('title', 'order', 'is_active')
    list_filter = ('is_active',)
    search_fields = ('title', 'subtitle')
    list_editable = ('order', 'is_active')

@admin.register(Office)
class OfficeAdmin(admin.ModelAdmin):
    list_display = ('name', 'phone', 'email', 'is_headquarters')
    list_filter = ('is_headquarters',)
    search_fields = ('name', 'address', 'phone', 'email')
